﻿@model PopForums.Models.ForumTopicContainer
@using PopForums.Controllers
@using PopForums.Extensions;
@{
	ViewBag.Title = Model.Forum.Title;
    Layout = "~/Areas/PopForums/Views/Shared/PopForumsMaster.cshtml";
}

@section HeaderContent{
@if (this.GetUserFromViewData() != null) {
	<script src="~/scripts/tiny_mce/jquery.tinymce.js" type="text/javascript"></script>
}
<script type="text/javascript">
	$(function () {
		PopForums.topicListSetup(@Model.Forum.ForumID);
		@if (Model.PagerContext.PageIndex == 1)
		{
			<text>PopForums.forumListen(@Model.PagerContext.PageSize, @Model.Forum.ForumID);</text>
		}
	});
</script>
}

<div id="TopBreadcrumb" class="navAbsolute">
	<h1>@Model.Forum.Title</h1>
	<p>
		@Html.ActionLink(PopForums.Resources.Recent, "Recent", ForumController.Name, new { page = 1 }, null)
		^ @Html.ActionLink(PopForums.Resources.Forums, "Index", ForumHomeController.Name, null, null)
	</p>
</div>

@if (Model.PermissionContext.UserCanPost) {
	<div id="NewTopic" style="display: none;"></div>
	<input type="button" value="@PopForums.Resources.PostNewTopic" id="NewTopicButton" class="toolButton" />
} else {
	<p>@Model.PermissionContext.DenialReason</p>
}

@Html.PagerLinks("Forum", "Index", Model.PagerContext, "pagerLinks", "morePager", "currentPager")

@if (this.GetUserFromViewData() != null)
{
	using (Html.BeginForm("MarkForumRead", "Forum", new { id = Model.Forum.ForumID }))
	{
		<input type="submit" value="@PopForums.Resources.MarkForumRead" class="toolButton" />
	}
}

<table class="forumGrid">
	@foreach (var topic in Model.Topics) {
		<tr @if(topic.IsDeleted) {<text> class="deletedItem"</text> } data-topicID="@topic.TopicID">
			<td class="newIndicator">
				@if (this.GetUserFromViewData() == null)
				{
					<a href="@Url.Action("Topic", "Forum", new { id = topic.UrlName, page = 1 })">@Html.TopicReadIndicator(topic, Model, "/Content/PopForums/")</a>
				}
				else
				{
					<a href="@Url.Action("GoToNewestPost", "Forum", new { id = topic.TopicID })">@Html.TopicReadIndicator(topic, Model, "/Content/PopForums/")</a>
				}
			</td>
			<td>
				<h2>@Html.ActionLink(topic.Title, "Topic", "Forum", new { id = topic.UrlName, page = 1 }, null) <span class="topicPreviewButton" title="@PopForums.Resources.PreviewTopic" topicID="@topic.TopicID">&gt;&gt;</span></h2>
				<div id="TopicPreview@(topic.TopicID)" class="topicPreview"></div>
				<p class="forumStatData">
					@PopForums.Resources.StartedBy: @topic.StartedByName | @PopForums.Resources.Views: @topic.ViewCount.ToString("N0") | @PopForums.Resources.Replies: @topic.ReplyCount.ToString("N0") | @PopForums.Resources.Last: <span class="lastPostTime fTime" data-utc="@FormatTime8601(topic.LastPostTime)">@FormatTime(topic.LastPostTime)</span> @PopForums.Resources.By @topic.LastPostName
				</p>
			</td>
		</tr>
	}
	<tr id="TopicTemplate" data-topicID="">
		<td class="newIndicator">
			<a class="indicatorLink" href=""><img src=""/></a>
		</td>
		<td>
			<h2><a class="titleLink" href=""></a> <span class="topicPreviewButton" title="@PopForums.Resources.PreviewTopic" topicID="">&gt;&gt;</span></h2>
			<div id="" class="topicPreview"></div>
			<p class="forumStatData">
				@PopForums.Resources.StartedBy: <span class="startedByName"></span> | @PopForums.Resources.Views: <span class="viewCount"></span> | @PopForums.Resources.Replies: <span class="replyCount"></span> | @PopForums.Resources.Last: <span class="lastPostTime fTime" data-utc=""></span> @PopForums.Resources.By <span class="lastPostName"></span>
			</p>
		</td>
	</tr>
</table>

@Html.PagerLinks("Forum", "Index", Model.PagerContext, "pagerLinks", "morePager", "currentPager")

